@extends('admin.layout.common')
@section('content')
    <link rel="stylesheet" type="text/css" href="{{URL::asset('css/user/AgentDetails.css')}}">
    <link rel="stylesheet" type="text/css" href="{{URL::asset('css/user/AgentInformationViewing.css')}}">
    <link rel="stylesheet" type="text/css" href="{{URL::asset('css/user/StatisticalControl.css')}}">
    <div class="content">
        <div class="mon">
            <div class="mon_left">
                <p>
                    <i class="iconfont icon gongzuo">&#xe647;</i>
                    <span>{{date('Y年m月d日')}}  本月已开户{{ session('monthPass') }}个  打回{{session('monthRefuse')}}个</span>
                <p>超过了{{ session('monthPrecent') }}的三咖审核员，继续努力！从此踏上人生巅峰，迎娶白富美！</p>
                </p>
            </div>
            <div class="mon_right">
                <p>您今天已经开户{{session('todayPass')}}个    打回{{session('todayRefuse')}}个</p>
                <p>超过了{{session('todayPrecent')}}的三咖开户员哦~棒棒哒！！！</p>
            </div>
        </div>
        <p class="tongzhi"><i class="iconfont icon laba">&#xe914;</i>{{getArticleByDepartmentId()}}</p>
        <!-- 公共结束 -->
        <div class="message_box">
            <h1 class="h1">代理信息查看<i class="icon iconfont binaji" onclick="javascript:window.location.href='{{url('admin/updateAgent/'.$v['id'])}}'" style="cursor:pointer;">&#x545;</i></h1>
            <p class="add"></p>
            <div class="message_big">
                <div class="message_left">
                    <div class="quancheng" style="width: 400px;">
                        <form action="">
                            <p><label>全称：{{$v['full_name']}}</label>

                            <p><label>简称：{{$v['simple_name']}}</label>

                            <p><label>性质：{{$v['agent_type']}}</label>

                            <p><label>证件：{{$v['card_type']}}</label>

                            <p><label>证件号：{{$v['card']}}</label>

                            <p><label>分比：{{$v['scale']}}</label>

                            <p><label>协议：<a href="http://{{$_SERVER['HTTP_HOST'].$v['protocol_file']}}">查看协议</a></label>

                            <p><label>签约日：{{$v['fix_date']}}</label>

                            <p><label>到期日：{{$v['expired_time']}}</label>
                                <div>
                                    <button class="update-btn btn" type="button" style="float:left;border:1px solid;border-radius:5px;margin-right:10px;background-color:#CF2121" onclick=update("{{$v['id']}}",'代理') >更新协议</button>
                                    <button class="update-btn btn" type="button" style="float:left;border:1px solid;border-radius:5px;background-color:#CF2121" onclick=doStop({{$v['id']}})>终止协议</button>
                                </div>
                            </p>
                            <p><label>联系人：{{$v['phone_name']}}</label>

                            <p><label>固定电话：{{$v['telephone']}}</label>

                            <p><label>移动电话：{{$v['phone']}}</label>

                            <p><label>违规记录:</label>
                            @foreach($v['deal'] as $d)
                            <p>{{$d['create_at']}}  @if($d['deal_type'] != 100)停{{$d['deal_type']}}天@else 永久停用 @endif</p>
                            <p>{{$d['remark']}}</p>
                            @endforeach
                        </form>
                    </div>
                    <div class="zhuying" style="width: 300px;">
                        <form action="">
                            <p><label>微信：{{$v['weixin']}}</label>

                            <p><label>微博：{{$v['weibo']}}</label>

                            <p><label>email:{{$v['email']}}</label>

                            <p><label>网址：{{$v['url']}}</label>

                            <p><label>对应软ID：{{$v['software_id']}}</label>

                            <p><label>主营业务员：{{$v['main']}}</label>

                            <p><label>辅助业务员：{{$v['assist']}}</label>

                            <p><label>纪念日：</label>
                            @if($v['memory_day'])
                                @foreach($v['memory_day'] as $vv)
                                    <p><label>{{$vv['des']}}：{{$vv['day']}}</label>
                                @endforeach
                            @endif
                            <p>
                                <label>代理数：</label>
                                <div style="float:left;width: 200px">
                                    <label style="float: left">已有代理:{{$v['users_info_count']}}</label>
                                    <button class="update btn" type="button" style="float:right;border:1px solid;border-radius:5px;background-color:#CF2121" onclick=user('{{$v['software_id']}}')>查看</button>
                                </div>
                            </p>
                            <p><label>代理状态：@switch($v['status'])
                                        @case (1)
                                        注销
                                        @break
                                        @case (2)
                                        正常
                                        @break
                                        @case (3)
                                        暂时停用
                                        @break
                                    @endswitch</label>

                            <p><label>合作简述：{{$v['protocol']}}</label>

                        </form>
                    </div>
                </div>
                <div class="message_right">
                    <form action="">
                        <p><label>备注：</label>
                        <p><label>{{$v['remark']}}</label></p>
                    </form>
                </div>
            </div>
            <button type="button" class="btn btn_dianji weigui" onclick=renew({{$v['id']}})>恢复账号</button>
            <button type="button" class="btn btn_dianji weigui" onclick=weigui("{{$v['id']}}",'代理')>违约处理</button>
            <button type="button" class="btn btn_dianji zhuxiao" onclick=doStop({{$v['id']}})>注销代理</button>
        </div>
    </div>
<script>
    //	协议弹窗
    function update(id,type){
        layer.open({
            type: 2,
            skin: '', //加上边框
            area: ['650px', '400px'], //宽高
            content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/updateProtocol/' + id + '/' + type
            ,end:function(){
                location.reload();
            }
        });
    };
    //	违约弹窗
    function weigui(id,type){
        layer.open({
            type: 2,
            area: ['350px', '350px'], //宽高
            content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/deal/'+id+'/'+type
            ,end:function(){
                location.reload();
            }
        });
    }
    //查看用户
    function user(id){
        layer.open({
            type: 2,
            area: ['700px', '850px'], //宽高
            title:'代理详情',
            content: 'http://{{$_SERVER['HTTP_HOST']}}/admin/userByAgentId/'+id
        });
    }

    //终止协议
    function doStop(id){
        layer.open({
            content:'您确定终止协议（注销代理）吗？'
            ,yes: function(index, layero){
                window.location.href="{{url('admin/cancle')}}/"+id+"/代理";
            }
        })
    }
    //恢复账号
    function renew(id){
        layer.open({
            content:'您确定恢复此账号吗？'
            ,yes: function(index, layero){
                window.location.href="{{url('admin/renew')}}/"+id;
            }
        })
    }
</script>
@endsection
